<template>
  <div class="p-index">
    <el-container class="p-el-container">
      <el-header>
        <div class="p-header">
          <div class="p-title">
            <div>
              <img src="../assets/logo.png" alt="" />
            </div>
          </div>
          <div class="search">
            <el-input
              placeholder="请输入内容"
              v-model="searchValue"
              class="input-with-select"
            >
              <el-button slot="append" icon="el-icon-search"></el-button>
            </el-input>
          </div>
          <div class="p-user">
            <el-dropdown trigger="click" @command="handleClick">
              <el-tag>
                {{ getUser }}
                <i class="el-icon-caret-bottom"></i>
              </el-tag>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item command="exit"
                  >退出登录</el-dropdown-item
                >
              </el-dropdown-menu>
            </el-dropdown>
          </div>
        </div>
      </el-header>
      <el-container>
        <el-aside>
          <p-menu></p-menu>
        </el-aside>
        <el-main>
          <el-container class="main-container" direction="vertical">
            <!-- <p-tabs></p-tabs> -->
            <div class="pages">
                <router-view></router-view>
            </div>
          </el-container>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
//引用Menu组件
import PMenu from "../components/Menu.vue";
export default {
  components: {
    PMenu,
  },
  data() {
    return {
      getUser: "SunRan",
      searchValue: "",
    };
  },
  methods: {
    async handleClick(command) {
      if (command == "exit") {
        let res = await this.$confirm("正在退出系统", "提示", {
          type: "warning",
        }).catch((err) => err);
        if (res == "confirm") {
          delete sessionStorage.userInfo;
          delete sessionStorage.token;
          delete sessionStorage.menuList;
          this.$router.push("/login");
        }
      }
    },
  },
};
</script>

<style lang="scss" >
header {
  height: 90px !important;
}
.p-header {
  top: 0;
  right: 0;
  left: 300px;
  height: 90px;
  box-shadow: 0px 2px 5px 0px rgb(0 0 0 / 10%);
  background: #f5f5f5;
  padding: 0px 15px;
  .p-title {
    // display: inline-block;
    float: left;
    img {
      margin-left: 20%;
      margin-top: 10%;
    }
  }
  .search {
    margin-left: 15%;
    float: left;
    width: 30%;
  }
  .p-user {
    display: inline-block;
    cursor: pointer;
    float: right;
  }
}
.p-index {
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  .p-el-container {
    height: 100%;
    overflow: auto;
    .el-container {
      overflow: auto;
    }
    .el-header {
      padding: 0;
      height: 90px;
      line-height: 90px;
      color: #fff;
    }
    .el-aside {
      background-color: #fff;
      padding: 0;
    }
    .el-main {
      padding: 0;
      background-color: #cccccc;
      .main-container {
        height: 100%;
        display: flex;
        flex-direction: column;
        .pages {
          background: #e5e5e5;
          flex-grow: 1;
          overflow: auto;
          max-height: 100%;
          padding: 0px 15px;
        }
      }
    }
  }
}
</style>
